{extend name="public:base" /}
{block name="content"}	
<div class="page-header">
	<h1>
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$crumbs}
		</small>			
	<button type="submit" style="float:right;" id='send' form="form-goods"  class="btn button btn-sm btn-primary">提交</button>
	</h1>
</div>
	<div class="row">
	<div class="col-xs-12">	
		<div class="panel-body">
        <form action="{:url('Goods/edit_general')}" method="post" enctype="multipart/form-data" id="form-goods" class="form-horizontal">
        
        {if condition="$Request.param.id"}
			<input name="goods_id" type="hidden" value="{$Request.param.id}" />
		{/if}
          <ul class="nav nav-tabs">
          	
          	<li class="active"><a href="#tab-data" data-toggle="tab">基本信息</a></li>
            <li><a href="#tab-general" data-toggle="tab">商品描述</a></li>
          </ul>
          <div class="tab-content">
          		
	          	<!-- 基本信息 START -->
	          	<div class="tab-pane active" id="tab-data">
	          		
	          		<div class="form-group required">
		                <label class="col-sm-2 control-label" for="input-image">
		                <span title="" data-toggle="tooltip" data-original-title="上传800x800的图片">缩略图：</span>
		                </label>
		                
		                <div class="col-sm-10" id="thumb">
		                  <a id="thumb-image" href="#" data-toggle="image" class="img-thumbnail">
		                  		{if condition="!empty($goods['image'])"}
		                  			<img src="IMG_ROOT{$goods.image|resize=100,100}" />
			                  	{else /}
			                  		<img src="__PUBLIC__/image/no_image_100x100.jpg" />
			                  	{/if}
								</a>
		                  <input type="hidden" name="image" value="{$goods.image}" id="input-image" />
		            </div>
		            
		            </div>   
		            
		            <div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">商品名称：</label>
						<div class="col-sm-10">
							<input id="input-name2" class="form-control" type="text" placeholder="商品名称" value="{$goods.name}" name="name">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-length-class">代理商：</label>
						<div class="col-sm-10">

							<select id="input-length-class" class="form-control" name="agent_id">
								<option value="0" {if condition="$goods.agent_id eq 0"} selected {/if}>管理者</option>
								{volist name="agent" id="agent"}
								<option value="{$agent.agent_id}" {if condition="$goods.agent_id eq $agent.agent_id"} selected {/if}>{:get_agent_name($agent.uid)}</option>
								{/volist}
							</select>
						</div>
					</div>
		            <div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">销量：</label>
						<div class="col-sm-10">
							<input id="input-name2" class="form-control" type="text" placeholder="销量" value="{$goods.sale_count}" name="sale_count">
						</div>
					</div>
					
		            <div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">商品型号：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="商品型号" value="{$goods.model}" name="model">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">库存单位：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="库存单位" value="{$goods.sku}" name="sku">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">生产地：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="商品位置" value="{$goods.location}" name="location">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" >市场价：</label>
						<div class="col-sm-10">
							<input  class="form-control" type="text" placeholder="市场价" value="{$goods.market_price}" name="market_price">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">销售价格：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="销售价格" value="{$goods.price}" name="price">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">商品数量：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="商品数量" value="{$goods.quantity}" name="quantity">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">购买可得积分：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="购买可得积分" value="{$goods.points}" name="points">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">兑换所需积分：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="兑换所需积分" value="{$goods.pay_points}" name="pay_points">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">最小订定量：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="最小起定量" value="{$goods.minimum}" name="minimum">
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-subtract">扣减库存：</label>
						
							<div class="col-sm-10">
								<label class="radio-inline">
								<input type="radio" checked="checked" value="1" name="subtract">是</label>
								<label class="radio-inline">
								<input type="radio" value="0" name="subtract">否</label>
							</div>
						
					</div>
		            
		           
					
					<div class="form-group">
						<label class="col-sm-2 control-label">需要配送：</label>
						<div class="col-sm-10">
							<label class="radio-inline">
							<input type="radio" checked="checked" value="1" name="shipping">是</label>
							<label class="radio-inline">
							<input type="radio" value="0" name="shipping">否</label>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">
							免运费：	
						</label>
						<div class="col-sm-10">
							<label class="radio-inline">							
							<input type="radio" checked="checked" value="0" name="free_shipping">否</label>
							<label class="radio-inline">
							<input type="radio" value="1" name="free_shipping">是</label>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-length-class">商品类型：</label>
						<div class="col-sm-10">
							
							<select id="input-length-class" class="form-control" name="type">
								{volist name="goods_type" id="t"}
									<option {if condition="$goods['type'] eq $t['id'] "} selected="selected"{/if} value="{$t.id}">{$t.name}</option>
								{/volist}
							</select>
						</div>
					</div>
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">重量：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="重量" value="{$goods.weight}" name="weight">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-length-class">重量单位：</label>
						<div class="col-sm-10">
							
							<select id="input-length-class" class="form-control" name="weight_class_id">
								{volist name="weight_class" id="v"}
									<option {if condition="isset($goods)&&($v.weight_class_id eq $goods['weight_class_id'])"}selected="selected"{/if} value="{$v.weight_class_id}"  >{$v.title}</option>
								{/volist}
							</select>
						</div>
					</div>
		            
		            <div class="form-group">
						<label class="col-sm-2 control-label" for="input-length">尺寸(L x W x H)：</label>
						<div class="col-sm-10">
							<div class="row">
								<div class="col-sm-4">
									<input id="input-length" class="form-control" type="text" placeholder="长度" value="{$goods.length|default=''}" name="length">
								</div>
								<div class="col-sm-4">
									<input id="input-width" class="form-control" type="text" placeholder="宽度" value="{$goods.width|default=''}" name="width">
								</div>
								<div class="col-sm-4">
									<input id="input-height" class="form-control" type="text" placeholder="高度" value="{$goods.height|default=''}" name="height">
								</div>
							</div>
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-length-class">尺寸单位：</label>
						<div class="col-sm-10">
							
							<select id="input-length-class" class="form-control" name="length_class_id">
								{volist name="length_class" id="v"}
									<option {if condition="isset($goods)&&($v.length_class_id eq $goods['length_class_id'])"}selected="selected"{/if} value="{$v.length_class_id}">{$v.title}</option>
								{/volist}
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">是否在首页显示：</label>
						<div class="col-sm-10">
							<label class="radio-inline">
								<input type="radio" checked="checked" value="1" name="is_home">是</label>
							<label class="radio-inline">
								<input type="radio" value="0" name="is_home">否</label>
						</div>
					</div>
		            <div class="form-group">
						<label class="col-sm-2 control-label">商品状态：</label>
						<div class="col-sm-10">
							<label class="radio-inline">
							<input type="radio" checked="checked" value="1" name="status">启用</label>
							<label class="radio-inline">
							<input type="radio" value="2" name="status">停用</label>
						</div>
					</div>
		            
		            <div class="form-group required">
						<label class="col-sm-2 control-label" for="input-meta-title2">排序：</label>
						<div class="col-sm-10">
							<input id="input-meta-title2" class="form-control" type="text" placeholder="排序" value="{$goods.sort_order}" name="sort_order">
						</div>
					</div>
		            
	          	</div>
	          	<!-- 基本信息 END -->
	          	
	          	<!-- 商品描述  START -->
	          	<div class="tab-pane" id="tab-general">	          		
					
					<div class="form-group">
	                    <label class="col-sm-2 control-label" for="input-description">商品简介：</label>
	                    <div class="col-sm-10">
	                      <textarea name="description[summary]" class="form-control" rows="5">{$description.summary|default=''}</textarea>	
	                    </div>
                  	</div>
					
					<div class="form-group">
	                    <label class="col-sm-2 control-label" for="input-description">商品详情：</label>
	                    <div class="col-sm-10">
	                      <textarea name="description[description]" id="description">{$description.description|default=''}</textarea>	
	                    </div>
                  	</div>
		
					
					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-meta-description2">Meta标签描述：</label>
						<div class="col-sm-10">
							<textarea id="input-meta-description2" class="form-control" placeholder="Meta标签描述" rows="5" name="description[meta_description]">{$description.meta_description|default=''}</textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label" for="input-meta-keyword2">Meta标签关键词：</label>
						<div class="col-sm-10">
							<textarea id="input-meta-keyword2" class="form-control" placeholder="Meta标签关键词" rows="5" name="description[meta_keyword]">{$description.meta_keyword|default=''}</textarea>
						</div>
					</div>
					
					
					
	          	</div>
	          	<!-- 商品描述 END -->  
	          	
        
          </div>
        </form>
	</div>
	</div>
</div>
{/block}
{block name="javascript"}	
<script src="__PUBLIC__/js/ckeditor/ckeditor.js"></script> 
<script>
$(function(){
	{if condition="$Request.param.id"}
				Oscshop.setValue("status", {$goods.status|default=1});		
				Oscshop.setValue("subtract",{$goods.subtract|default=1});		
				Oscshop.setValue("shipping",{$goods.shipping|default=1});
				Oscshop.setValue("free_shipping",{$goods.free_shipping|default=0});
	{/if}
});	

$('#send').click(function(){
	
	var name=$('input[name="name"]').val();
	
	if(name==''){
		alert('商品名称必填');
		return false;
	}	
	
	return true;
}); 


CKEDITOR.replace('description', {
	filebrowserImageUploadUrl: '{:url("FileManager/ckupload")}',	
	toolbar: [
				[ 'Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ],
				[ 'FontSize', 'TextColor', 'BGColor' ],
				[ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock','Image','Format']
			]	
});
</script>
{/block}